package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//处理异常
@RestControllerAdvice
public class GlobalExceptionHandle {
    @ExceptionHandler(leaseException.class)
    public Result resolveLeaseException(leaseException leaseException){
        leaseException.printStackTrace();//打印异常的堆栈信息
        return Result.fail(leaseException.getCode(),leaseException.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result resolveException(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}
